package com.nzw.utils;

import com.nzw.pojo.wx.MassageTemplate;
import com.nzw.pojo.wx.TemplateData;
import com.sun.org.apache.bcel.internal.generic.SWITCH;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by ywx on 2018/1/3/003.
 *
 * 微信模板消息工具类
 *
 */



public class MassageUtil {


    //庚申
//    public static final String PAYSUCCESS = "1nCRWDgxA2zIVfX5UlSPTdWMFy2XCtD6QXbmoMfYj3g";
//    public static final String RECHARGE_SUCCESS = "1wu9JcHYldDdgc3kXUXSs4ckMofr3TQ1yyDQzgrKmSA";
//    public static final String GIFT_EXCHANGE = "uTuf0geZmXhj9ajXSdPtKAxr1OwATsasnGnfUTNUwqk";

    //白沙
    public static final String PAYSUCCESS = "1fPbdffsIFNVbyLjLA84AMGxFql4f8vP_E1lZ6Knse4";              //支付加油成功
    public static final String RECHARGE_SUCCESS = "MDi0rczPCSdZapNviLcfv_8ev1PByCR8N7afpT3XIw0";        //充值成功
    public static final String GIFT_EXCHANGE = "Gui-GjLPtTUMpGdltfeH3fmGD0DG3rM1WYz1JuxPhfo";           //积分兑换
    public static final String SUCCESS_ATTEST = "H9aR_BqHiWouHKVGTczK2T0_gAPSAmOBSFJ30hBqC9g";          //认证成功
    public static final String FAIL_ATTEST = "6t4wGUs6HhVi2p3Yt_cC6E8EO_WTpHEVt8Hqt-im6fw";            //认证失败
    private static final String COUPONTOUSER = "EVPmUvm3IinguHNf3rKQcBb2oaH_pFBy1Rfa0DAZ6cc";          //礼品领取成功通知 优惠券消息


    public static MassageTemplate createMsgTemplate(String type){

        MassageTemplate temp = new MassageTemplate();
        temp.setTemplate_id(type);
        Map<String,TemplateData> m = new HashMap<String,TemplateData>();

        temp.setData(m);
        return  temp;

    }



    public static MassageTemplate couponToUser(String openid,String createDate,String endDate){

        MassageTemplate template = MassageUtil.createMsgTemplate(MassageUtil.COUPONTOUSER);
        System.out.println("消息模板id:"+template.getTemplate_id());
        template.setTouser(openid);
        Map<String,TemplateData> m = new HashMap<String,TemplateData>();
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("恭喜礼品领取成功");
        m.put("first", first);
        //参数一
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("优惠券");
        m.put("keyword1", keyword1);
        //参数二
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(createDate);
        m.put("keyword2", keyword2);

        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("至"+endDate);
        m.put("keyword3", keyword3);
        template.setData(m);

        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("礼品已成功领取,请在规定时间内使用,过期请归还");
        m.put("remark", remark);
        template.setData(m);

        return  template;

    }




    //认证失败提醒
    public static MassageTemplate attestFail(String openid,String carType,String reason){

        MassageTemplate template = MassageUtil.createMsgTemplate(MassageUtil.FAIL_ATTEST);
        System.out.println("消息模板id:"+template.getTemplate_id());
        template.setTouser(openid);
        Map<String,TemplateData> m = new HashMap<String,TemplateData>();
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("您好，你提交的"+carType+"认证信息审核");
        m.put("first", first);
        //参数一
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("不通过");
        m.put("keyword1", keyword1);
        //参数二
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(reason);
        m.put("keyword2", keyword2);

        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("请及时确认审核消息，如有疑问请及时反馈");
        m.put("remark", remark);
        template.setData(m);

        return  template;

    }








    //认证成功提醒
    public static MassageTemplate attestSuccess(String openid,String carType){

        MassageTemplate template = MassageUtil.createMsgTemplate(MassageUtil.SUCCESS_ATTEST);
        System.out.println("消息模板id:"+template.getTemplate_id());
        template.setTouser(openid);
        Map<String,TemplateData> m = new HashMap<String,TemplateData>();
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("您好, 您提交的"+carType+"认证信息已经审核");
        m.put("first", first);
        //参数一
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("已通过");
        m.put("keyword1", keyword1);
        //参数二
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(DateTimeUtilT.dateTime(new Date()));
        m.put("keyword2", keyword2);

        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("请及时确认审核消息，如有疑问请及时反馈");
        m.put("remark", remark);
        template.setData(m);

        return  template;

    }








    public static MassageTemplate giftExchange(String openid,String commodityName,String note,String shopName,int payIntegral,int haveIntegral){

        MassageTemplate template = MassageUtil.createMsgTemplate(MassageUtil.GIFT_EXCHANGE);
        System.out.println("消息模板id:"+template.getTemplate_id());
        template.setTouser(openid);
        Map<String,TemplateData> m = new HashMap<String,TemplateData>();
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("恭喜您积分礼品兑换成功！");
        m.put("first", first);
        //参数一
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(commodityName);
        m.put("keyword1", keyword1);
        //参数二
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(shopName);
        m.put("keyword2", keyword2);

        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue(payIntegral +"积分");
        m.put("keyword3", keyword3);
        template.setData(m);

        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(haveIntegral+"积分");
        m.put("keyword4", keyword4);
        template.setData(m);

        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("兑换明细:"+note);
        m.put("remark", remark);
        template.setData(m);

        return  template;

    }







    public static MassageTemplate rechargeSuccess(String openid,String shopName,int payMoney,String nick,int giftMoney){

        MassageTemplate template = MassageUtil.createMsgTemplate(MassageUtil.RECHARGE_SUCCESS);
        System.out.println("消息模板id:"+template.getTemplate_id());
        template.setTouser(openid);
        Map<String,TemplateData> m = new HashMap<String,TemplateData>();
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("您的商品购买成功");
        m.put("first", first);
        //参数一
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("IC卡充值");
        m.put("keyword1", keyword1);
        //参数二
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(shopName+"加油卡");
        m.put("keyword2", keyword2);

        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue(payMoney/100.00 +"元");
        m.put("keyword3", keyword3);
        template.setData(m);

        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue("微信昵称"+nick);
        m.put("keyword4", keyword4);
        template.setData(m);

        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("备注:实际支付金额"+payMoney/100.00 +"元,赠送金额"+giftMoney/100.0+"元,合计充值金额"+(payMoney+giftMoney)/100.0+"元，充值时间"+DateTimeUtilT.dateTime(new Date()));
        m.put("remark", remark);
        template.setData(m);

        return  template;


    }










    public static MassageTemplate paySuccess( String openid,String oilCode,Double oilNumber,int payMoney,String note){

        MassageTemplate template = MassageUtil.createMsgTemplate(MassageUtil.PAYSUCCESS);
        System.out.println("消息模板id:"+template.getTemplate_id());
        template.setTouser(openid);
        Map<String,TemplateData> m = new HashMap<String,TemplateData>();
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("尊敬的客户您好！");
        m.put("first", first);
        //参数一
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(oilCode);
        m.put("keyword1", keyword1);
        //参数二
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(oilNumber+"升");
        m.put("keyword2", keyword2);

        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue(payMoney/100.00 +"元");
        m.put("keyword3", keyword3);
        template.setData(m);

        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("备注:"+note);
        m.put("remark", remark);
        template.setData(m);

        return  template;

    }


}
